package com.meixiang.adapter.personalCenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meixiang.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author yinsujun  Created at 2016/5/6 14:14
 */
public class MoneyManagementAdapter extends RecyclerView.Adapter<MoneyManagementAdapter.ViewHolder> {
    private Context context;

    public MoneyManagementAdapter(Context context) {
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.fragment_money_management_list_item, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        if (mOnItemClickListener != null) {
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int pos = holder.getLayoutPosition();
                    mOnItemClickListener.onItemClick(holder.itemView, pos);

                }
            });
        }
    }

    @Override
    public int getItemCount() {
        return 4;
    }
    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
        this.mOnItemClickListener = mOnItemClickListener;
    }

    public interface OnItemClickListener {
        void onItemClick(View view, int position);
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.money_management_tv_title)
        TextView tvTitle;
        @Bind(R.id.money_management_tv_investment_money)
        TextView tvInvestmentMoney;
        @Bind(R.id.money_management_tv_yield)
        TextView tvYield;
        @Bind(R.id.money_management_tv_time)
        TextView tvTime;
        @Bind(R.id.money_management_tv_limit)
        TextView tvLimit;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
